#pragma once
#include <windows.h>
#include <gdiplus.h>
#include <string.h>
#include <iostream>

using namespace std;
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")

class Mygtukas
{
private:
	HWND hWnd;
	int x, y, width, height;
	int control_id;

	Bitmap *buttonBg;

public:
	Mygtukas(int x, int y, int width, int height, HWND hWnd, int control_id, WCHAR imgPath[], int imgX, int imgY)
	{
		this->hWnd = hWnd;
		this->x = x;
		this->y = y;
		this->width = width;
		this->height = height;
		this->control_id = control_id;

		// Randa exe kelia
		WCHAR buffer[MAX_PATH];
		GetModuleFileNameW(NULL, buffer, sizeof(buffer));
		wstring exeDir = buffer;
		int place = exeDir.find_last_of('\\');
		exeDir = exeDir.substr(0, place);
		_wchdir(exeDir.c_str());

		//wstring imPat = imgPath;
		int counter = 0;
		for(int i = place+1; i < MAX_PATH; i++)
		{
			buffer[i] = imgPath[counter];
			if(imgPath[counter] == '\0')
			{
				break;
			}
			counter++;
		}

		

		/*WCHAR imgPath2[MAX_PATH];
				for(int i = 0; i < place; i++)
				{
					imgPath2[i] = exeDir[i];
				}*/

		//wstring filePath = exeDir;

		//string exeDir1(filePath.begin(), filePath.end());
		//exeDir1.assign(filePath.begin(), filePath.end());

		//// Confige nurodom naujo playlisto vieta
		//mConfig->setString("PlayListPath", exeDir1);


		buttonBg = new Bitmap(width, height);
		Bitmap *b = new Bitmap(buffer); //L"img\\bitmap.bmp"
		Graphics *fromImgButtonBg = Graphics::FromImage(buttonBg);
		fromImgButtonBg->DrawImage(b, 0, 0, imgX, imgY, width, height, UnitPixel);

		delete b;
		delete fromImgButtonBg;
	}

	~Mygtukas()
	{
		delete buttonBg;
	}

	void click();
	void update();
	void draw(HDC hdc);
};